package com.kfm.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/text")
public class TextServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
//        response.setHeader("content-type", "text/html;charset=UTF-8");
        response.setContentType("text/html;charset=UTF-8");
//        response.setContentType("text/plain;charset=UTF-8");

//        response.setCharacterEncoding("utf-8");

        PrintWriter writer = response.getWriter();

        writer.write("<h1>Hello World</h1>");
        writer.write("<hr>");
        writer.write("<h2>你好啊</h2>");
    }
}
